<?php 
# 文件名称:language.view.php
# MetInfo在线反馈系统 
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
class languageView extends C_view
{
	function languageView()
	{
		parent::C_view();
	}
	//加载模板
	function display($tpl)
	{		
		$SYS = &get_instance();
		$class = $SYS->request->getVar('option', '', 'get');
		$class = $class==''?$SYS->request->getvar('option') : $class;
		$SYS->html->script('core.js');
		$this->assignRef('message', $SYS->loader->getMessageQueue());
		switch($class)
		{			
			case 'administrator':$this->getAdministrator($tpl);break;
			default:$this->getSite($tpl);
		}
	}
	//后台语言模板
	function getAdministrator($tpl)
	{		
		switch($tpl)
		{			
			case 'add':		
							$this->assignRef( 'subTitle',C_text::_('AddLanguage'));
							$this->assignRef('item', $this->get('Item'));
							$SYS = &get_instance();
							$this->assignRef('langs', $SYS->lang->languagelist(2));
							$this->getJS();
							$this->assign('lang_type', "2");							
							$this->assign('apply', "add");
							parent::display('language_edit');break;
			case 'edit':
							$this->assignRef( 'subTitle',C_text::_('EditLanguage'));
							$this->assignRef('item', $this->get('Item'));
							$SYS = &get_instance();
							$this->assignRef('langs', $SYS->lang->languagelist(2));
							$this->getJS();
							$this->assign('apply', "edit");
							parent::display('language_edit');break;
			case 'translate':
							$this->assignRef( 'subTitle',C_text::_('TranslateLanguage'));
							$this->assignRef('language', $this->get('Language'));
							$this->assignRef('lang', $this->get('Lang'));
							$this->assign('option', 'administrator');
							$this->assign('apply', "translate");
							$js_content="
							markRows();
							window.addEvent('domready', function(){ 
								new Accordion($$('.pane-toggler'), 
								$$('.pane-slider'), 
								{
									onActive: function(toggler, i) 
									{ 
										toggler.addClass('pane-toggler-down');toggler.removeClass('pane-toggler'); 
									},
									onBackground: function(toggler, i) 
									{ 
										toggler.addClass('pane-toggler'); toggler.removeClass('pane-toggler-down'); 
									},
									duration: 300,opacity: false,alwaysHide: true
								}); 
							});
							";
							$SYS = &get_instance();
							$SYS->doc->addScriptDeclaration($js_content);
							$SYS->html->script('mootools-more.js');
							parent::display('language_translate');break;
			default:
							$this->assignRef( 'items', $this->get('AdminItems'));
							$this->assignRef( 'lists', $this->get('Lists'));
							parent::display('language_admin');
		}
	}
	//前台语言模板
	function getSite($tpl)
	{		
		switch($tpl)
		{			
			case 'add':		
							$this->assignRef( 'subTitle',C_text::_('AddLanguage'));
							$this->assignRef('item', $this->get('Item'));
							$SYS = &get_instance();
							$this->assignRef('langs', $SYS->lang->languagelist(1));
							$this->getJS();
							$this->assign('lang_type', "1");
							$this->assign('apply', "add");
							parent::display('language_edit');break;
			case 'edit':
							$this->assignRef( 'subTitle',C_text::_('EditLanguage'));
							$this->assignRef('item', $this->get('Item'));
							$SYS = &get_instance();
							$this->assignRef('langs', $SYS->lang->languagelist(1));
							$this->getJS();
							$this->assign('apply', "edit");
							parent::display('language_edit');break;
			case 'translate':
							$this->assignRef( 'subTitle',C_text::_('TranslateLanguage'));
							$this->assignRef('language', $this->get('Language'));
							$this->assignRef('lang', $this->get('Lang'));
							$this->assign('option', 'site');
							$this->assign('apply', "translate");
							$js_content="
							markRows();
							window.addEvent('domready', function(){ 
								new Accordion($$('.pane-toggler'), 
								$$('.pane-slider'), 
								{
									onActive: function(toggler, i) 
									{ 
										toggler.addClass('pane-toggler-down');toggler.removeClass('pane-toggler'); 
									},
									onBackground: function(toggler, i) 
									{ 
										toggler.addClass('pane-toggler'); toggler.removeClass('pane-toggler-down'); 
									},
									duration: 300,opacity: false,alwaysHide: true
								}); 
							});
							";
							$SYS = &get_instance();
							$SYS->doc->addScriptDeclaration($js_content);
							$SYS->html->script('mootools-more.js');
							parent::display('language_translate');break;
			default:
							$this->assignRef( 'items', $this->get('SiteItems'));
							$this->assignRef( 'lists', $this->get('Lists'));
							parent::display('language_site');
		}
	}
	//加载js库
	function getJS()
	{
		$SYS = &get_instance();
		$js_content="
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			// do field validation
			if (trim(form.title.value) == '') {
				alert( '".C_text::_('Item1').C_text::_('Item7')."');
			} else if (trim(form.lang_code.value) == '') {
				alert( '".C_text::_('Item2').C_text::_('Item7')."' );
			} else {
				submitform( pressbutton );
			}
		}
		";
		$SYS->doc->addScriptDeclaration($js_content);
	}
	
}
# 本程序是一个开源系统,使用时请你仔细阅读使用协议,商业用途请自觉购买商业授权.
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
?>
	